package com.quwan.manager.controller;

import com.quwan.common.BaseController;
import com.quwan.common.result.ApiResult;
import com.quwan.common.result.PageResult;
import com.quwan.entity.TMemberClickNum;
import com.quwan.manager.service.MemberClickNumService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author laozhang
 * @date 2022/05/28
 */
@Api(tags = "后台用户点击事件管理接口")
@RestController
@RequiredArgsConstructor
@RequestMapping("mgr/memberClickNum")
public class MemberClickNumController extends BaseController {

    private final MemberClickNumService memberClickNumService;

    @ApiOperation("用户点击事件列表分页")
    @PostMapping("clickNumListPage")
    public ApiResult<PageResult<TMemberClickNum>> ClickNumListPage(@RequestParam(defaultValue = "1") int page,
                                                         @RequestParam(defaultValue = "10") int size,
                                                         @ApiParam("开始时间 格式：yyyy-MM-dd") @RequestParam(required = false) String beginTime,
                                                         @ApiParam("结束时间 格式：yyyy-MM-dd") @RequestParam(required = false) String endTime) {
        PageResult<TMemberClickNum> res = memberClickNumService.getMemberClickNumListPage(page,size,beginTime,endTime);
        return ApiResult.success(res);
    }

    @ApiOperation("用户点击事件列表")
    @PostMapping("clickNumList")
    public ApiResult<List<TMemberClickNum>> ClickNumList(
                                               @ApiParam("开始时间 格式：yyyy-MM-dd") @RequestParam(required = false) String beginTime,
                                               @ApiParam("结束时间 格式：yyyy-MM-dd") @RequestParam(required = false) String endTime) {
        List<TMemberClickNum> res = memberClickNumService.getMemberClickNumList(beginTime,endTime);
        return ApiResult.success(res);
    }


}
